package jxtcpclient

type Client struct {
	Address   string
	Pool      *Pool
	MachineId uint32
	MaxCount  int
	onMessage func(*Message)
	onClose   func(error)
}

func (c *Client) Close() {
	c.Pool.Close()
}
func NewClient(address string, maxcount int, machineid uint32, onmessage func(*Message), onclose func(error)) *Client {
	return &Client{
		Address:   address,
		MaxCount:  maxcount,
		MachineId: machineid,
		onMessage: onmessage,
		onClose:   onclose,
		Pool:      NewPool(address, machineid, maxcount, onmessage, onclose),
	}
}
func (c *Client) SendMessage(m *Message, f ...func(*Message)) (*Message, error) {
	return c.Pool.SendMessage(m, f...)
}
